#pragma once
#include <iostream>
class CIOCPRecvDataPackage
{
public:
	CIOCPRecvDataPackage(void);
	~CIOCPRecvDataPackage(void);

	int Package(char* _cArrBuffer, int _nLen);

	bool IsPackaged(){
		return m_nPackageLen != 0 && m_nPackageLen == m_nCurrentLen;
	}

	void Process();

	void Reset(){
		if (m_cArrBuffer)
		{
			free(m_cArrBuffer);
			m_cArrBuffer = NULL;
		}
		memset(m_cHead,0,4);
		m_nCurrentHeadLen = 0;
		m_nCurrentLen = 0;
		m_nPackageLen = 0;
	}

protected:

	int PackageHead(char* _cArrBuffer, int _nLen);

	int PackageContent(char* _cArrBuffer, int _nLen);

private:
	char m_cHead[4];
	int m_nCurrentHeadLen;
	char* m_cArrBuffer;
	int m_nCurrentLen;
	int m_nPackageLen;
};
